package org.mystock.candlestick.service.util;

import org.mystock.candlestick.model.DailyData;

public class CandleUtil {

	public static String getBodyColor(DailyData metrics) {
		return (metrics.getClose() > metrics.getOpen()) ? "white" : "black";
	}

	public static boolean checkShortUpperShadow(DailyData today,
			int allowedVariance) {
		return (today.getUpperShadowPercentWRTBody() <= allowedVariance);
	}

	public static boolean checkLongLowerShadow(DailyData today,
			int allowedVariance) {
		return (today.getLowerShadowPercentWRTBody() >= allowedVariance);
	}

	public static float getTrend(DailyData past, DailyData current) {

		float slope = ((current.getClose() - past.getClose()) / current
				.getClose()) * 100;

		return slope;
	}

	public static boolean isEngulfing(DailyData yesterday, DailyData today) {
		return yesterday.getOpen() < today.getOpen()
				&& yesterday.getClose() < today.getClose();
	}
}
